# - Try to find a Horde3D installation
# Once done, this will define
#
#  Horde3D_FOUND - system has Horde3D
#  Horde3D_INCLUDE_DIRS - the Horde3D include directories
#  Horde3D_LIBRARIES - link these to use Horde3D

include(LibFindMacros)

# Dependencies
libfind_package(Horde3D OpenGL)

# Use pkg-config to get hints about paths
libfind_pkg_check_modules(Horde3D_PKGCONF Horde3D)

# Include dirs
find_path(Horde3D_INCLUDE_DIR
	NAMES Horde3D.h
	PATHS ${Horde3D_PKGCONF_INCLUDE_DIRS}
	PATH_SUFFIXES horde3d
)

find_path(Horde3DUtils_INCLUDE_DIR
	NAMES Horde3DUtils.h
	PATHS ${Horde3D_PKGCONF_INCLUDE_DIRS}
	PATH_SUFFIXES horde3d
)

# Library locations
find_library(Horde3D_LIBRARY
  NAMES Horde3D Horde3D_vc8
  PATHS ${Horde3D_PKGCONF_LIBRARY_DIRS}
)

find_library(Horde3DUtils_LIBRARY
  NAMES Horde3DUtils Horde3DUtils_vc8
  PATHS ${Horde3D_PKGCONF_LIBRARY_DIRS}
)

# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.

# Stupid hack because includes are unset for windows
if (OPENGL_INCLUDE_DIR)
  set(Horde3D_PROCESS_INCLUDES Horde3D_INCLUDE_DIR Horde3DUtils_INCLUDE_DIR OPENGL_INCLUDE_DIR)
else (OPENGL_INCLUDE_DIR)
  set(Horde3D_PROCESS_INCLUDES Horde3D_INCLUDE_DIR Horde3DUtils_INCLUDE_DIR)
endif (OPENGL_INCLUDE_DIR)

set(Horde3D_PROCESS_LIBS Horde3D_LIBRARY Horde3DUtils_LIBRARY OPENGL_LIBRARIES)
libfind_process(Horde3D)

